package com.ms.game.slot.base;

import java.util.HashMap;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

public class SlotOptionBase {
	
	/**
	 * 停止 - 最大金額
	 */
	private long stopMaxMoney;
	
	/**
	 * 停止 - 最小金額
	 */
	private long stopMinMoney;
	
	/**
	 * 停止 - 彩金
	 */
	private boolean stopJP;
	
	/**
	 * 總回合數
	 */
	private int round;
	
	/**
	 * 單次獎金高於此值
	 */
	private long bigScoreMoney;
	
	/**
	 * 是否離線掛機
	 */
	private boolean isOfflinespin;
	
	/**
	 * 快速停輪
	 */
	private boolean isfastStop;
	
	/**
	 * 開出紅利遊戲或單機彩金
	 */
	private boolean isbounsgame;
	
	public boolean getIsbounsgame() {
		return isbounsgame;
	}

	public void setIsbounsgame(boolean isbounsgame) {
		this.isbounsgame = isbounsgame;
	}

	public boolean IsfastStop() {
		return isfastStop;
	}

	public void setIsfastStop(boolean isfastStop) {
		this.isfastStop = isfastStop;
	}

	public long getStopMaxMoney() {
		return stopMaxMoney;
	}

	public void setStopMaxMoney(long stopMaxMoney) {
		this.stopMaxMoney = stopMaxMoney;
	}

	public long getStopMinMoney() {
		return stopMinMoney;
	}

	public void setStopMinMoney(long stopMinMoney) {
		this.stopMinMoney = stopMinMoney;
	}

	public boolean isStopJP() {
		return stopJP;
	}

	public void setStopJP(boolean stopJP) {
		this.stopJP = stopJP;
	}

	public int getRound() {
		return round;
	}

	public void setRound(int round) {
		this.round = round;
	}

	public long getBigScoreMoney() {
		return bigScoreMoney;
	}

	public void setBigScoreMoney(long bigScoreMoney) {
		this.bigScoreMoney = bigScoreMoney;
	}

	public boolean isOfflinespin() {
		return isOfflinespin;
	}

	public void setOfflinespin(boolean isOfflinespin) {
		this.isOfflinespin = isOfflinespin;
	}
	
	
	@SuppressWarnings("unchecked")
	public void parse(String op) throws ParseException {
		JSONParser json = new JSONParser();

		HashMap<String, Object> data = (HashMap<String, Object>) json.parse(op);

		this.stopMaxMoney = Long.valueOf((String) data.get("maxmoney"));
		this.stopMinMoney = Long.valueOf((String) data.get("minmoney"));

		this.round = Integer.valueOf((String) data.get("round"));
		this.bigScoreMoney = Long.valueOf((String) data.get("bigscore"));
		this.isOfflinespin = (((String) data.get("offlinespin")).equals("1")) ? true : false;
		this.stopJP = (((String) data.get("stopjp")).equals("1")) ? true : false;

		this.isbounsgame = (((String) data.get("isbounsgame")).equals("1")) ? true : false;
		this.isfastStop = (((String) data.get("isfaststop")).equals("1")) ? true : false;
	}
	
	@SuppressWarnings("unchecked")
	public String assmbly()
	{
		JSONObject op=new JSONObject();
		op.put("maxmoney", String.valueOf(this.stopMaxMoney));
		op.put("minmoney", String.valueOf(this.stopMinMoney));
		op.put("round", String.valueOf(this.round));
		op.put("bigscore", String.valueOf(this.bigScoreMoney));
		op.put("offlinespin", (this.isOfflinespin)? "1":"0");
		op.put("stopjp", (this.stopJP)? "1":"0");
		op.put("isfaststop", (this.isfastStop)? "1":"0");
		op.put("isbounsgame", (this.isbounsgame)? "1":"0");
		return op.toJSONString();
	}
}
